
module demo(a, b, cin, sum, cout);

input [7:0] a, b;
input cin;
output cout;
output [7:0] sum;
wire [7:0] rr;
wire r;

assign {cout,sum} = a+b + cin + rr + r;

flatten u_flatten(a, b, r);
add u_add(a, b, rr);

endmodule

module add (
    a,
    b,
    c
);

input [7:0] a,b;
output [7:0] c;

assign c = a-b;
    
endmodule

module flatten (
    a,
    b,
    r
);

input a;
input b;
output reg r;

reg c;
reg d;
reg e;
reg f;


always @(*) begin
    c = a & b;
    d = b & c;
    e = d & c;
    f = e & d;
    r = f;
end
    
endmodule